﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using He.Web.UI;
using He.Common;

namespace He.Web.manage.ad
{
    public partial class effect_set : Manage
    {
        public int position_id;
        public Model.ad_position model;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!int.TryParse(Request.Params["position_id"] as string, out this.position_id))
            {
                ShowParamError();
                return;
            }
            model = new BLL.ad_position().GetModel(position_id);
            if (!this.Page.IsPostBack)
            {
                ddlDisplayEffect.DataSource = EnumHelper.GetList(typeof(Enums.FocusEffect));
                ddlDisplayEffect.DataTextField = "Text";
                ddlDisplayEffect.DataValueField = "Text";
                ddlDisplayEffect.DataBind();

                ddlDisplayEffect.SelectedValue = model.display_effect;
            }
        }

        protected void ddlDisplayEffect_SelectedIndexChanged(object sender, EventArgs e)
        {
            BLL.ad_position bll = new BLL.ad_position();
            model.display_effect = ddlDisplayEffect.SelectedValue;
            bll.Update(model);
            //更新缓存
            RemoveAdCache(model.call_mark);
            SaveLogs("[广告管理]更改展示方式");
            Response.Redirect(Request.RawUrl);
        }
    }
}